﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    public class Deposit: Transaction
    {
        public Decimal depositAmount;
        public String account;
        public Decimal commission;

        public Deposit()
        {
            this.account = "";
            this.depositAmount = 0;
            this.commission = 0;
        }

        public void depositMoney(String ATMType,BankDatabase bankDatabase)
        {
            for (int i = 0; i < bankDatabase.bankAccounts.Count; i++)
            {
                if (bankDatabase.bankAccounts[i].getID() == this.account)
                {
                    if (ATMType == "A")
                    {
                        if (bankDatabase.bankAccounts[i].getBank() == "A")
                        {
                            this.commission = 0;
                        }
                        else if (bankDatabase.bankAccounts[i].getBank() == "B")
                        {
                            this.commission = this.depositAmount * Convert.ToDecimal(0.03);
                        }

                        else if (bankDatabase.bankAccounts[i].getBank() == "C")
                        {
                            this.commission = this.depositAmount * Convert.ToDecimal(0.02) + 10;
                        }
                        else if (bankDatabase.bankAccounts[i].getBank() == "D")
                        {
                            if (this.depositAmount * Convert.ToDecimal(0.027) >= 10)
                                this.commission = this.depositAmount * Convert.ToDecimal(0.027);
                            else this.commission = 10;
                        }
                    }
                    else if (ATMType == "B")
                    {
                        if (bankDatabase.bankAccounts[i].getBank() == "A")
                        {
                            this.commission = this.depositAmount * Convert.ToDecimal(0.03);
                        }
                        else if (bankDatabase.bankAccounts[i].getBank() == "B")
                        {
                            this.commission = 0;
                        }

                        else if (bankDatabase.bankAccounts[i].getBank() == "C")
                        {
                            this.commission = this.depositAmount * Convert.ToDecimal(0.02) + 10;
                        }
                    }
                    bankDatabase.bankAccounts[i].increaseAmount(this.depositAmount);
                    bankDatabase.bankAccounts[i].decreaseAmount(this.commission);
                    break;
                }
            }
        }
    }
}
